Skip to content

Bundle the 8 math fonts (assets, plists, licenses, load test)#209

Merged
kostub merged 9 commits into
masterfrom
feature/add-math-fonts-pr1
May 30, 2026
Merged

Bundle the 8 math fonts (assets, plists, licenses, load test)#209
kostub merged 9 commits into
masterfrom
feature/add-math-fonts-pr1

Conversation

@kostub
Copy link
Copy Markdown
Owner

@kostub kostub commented May 30, 2026

Goal

Ship all 8 <key>.otf+<key>.plist pairs and their license/attribution files under iosMath/fonts/, and prove every key loads. No API or example-app change. Buildable & testable in isolation (swift test).

Plan: docs/plans/2026-05-30-add-math-fonts.md (items 1–8)
LLD: docs/lld/2026-05-30-add-math-fonts.md

Commits

  • [item 1] Add failing load test for all 8 bundled fonts
  • [item 2] Update XITS Math to v1.302 and regenerate plist
  • [item 3] Add New Computer Modern Math font + plist
  • [item 4] Add TeX Gyre Pagella Math font + plist
  • [item 5] Add STIX Two Math font + plist
  • [item 6] Add Fira Math font + plist
  • [item 7] Add Noto Sans Math font + plist
  • [item 8] Document the 8 bundled fonts and licenses in README

Font versions bundled

Loader key Font Version
xits-math XITS Math 1.302
newcm-math New Computer Modern Math 4.0
texgyrepagella-math TeX Gyre Pagella Math 1.632
stixtwo-math STIX Two Math 2.13b171
firamath Fira Math 0.3.4
notosansmath Noto Sans Math 3.000

Testing

All 267 tests pass. testAllBundledFontsLoad verifies every key resolves its .otf+.plist pair.

No Package.swift or .xcodeproj edits needed — all three build systems bundle fonts/ as a folder reference.

kostub and others added 8 commits May 30, 2026 21:15
TDD red step: testAllBundledFontsLoad iterates all 8 expected font keys
and asserts each loads with a non-nil font and mathTable. Test fails
(crashes on missing font files) because newcm-math, texgyrepagella-math,
stixtwo-math, firamath, and notosansmath are not yet bundled.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the bundled fonts and their licenses, modifies the math_table_to_plist.py script to ignore device tables instead of raising exceptions, and adds a test to verify that all bundled fonts load correctly. Feedback on the new test points out that asserting font is not nil is redundant because fontWithName:size: always returns an instance; instead, the test should assert that the internal CoreText font (font.ctFont) is not NULL to ensure successful loading.

Comment on lines +1640 to +1642
MTFont* font = [[MTFontManager fontManager] fontWithName:key size:20];
XCTAssertNotNil(font, @"Font %@ failed to load", key);
XCTAssertNotNil(font.mathTable, @"Font %@ has no math table", key);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The assertion XCTAssertNotNil(font, ...) is redundant and misleading because -[MTFontManager fontWithName:size:] always returns a non-nil MTFont instance (even if the underlying .otf or .plist files fail to load). To properly verify that the font files were successfully located and loaded, you should assert that the font's internal CoreText font (font.ctFont) is not NULL.

        MTFont* font = [[MTFontManager fontManager] fontWithName:key size:20];
        XCTAssertNotNil(font.mathTable, @"Font %@ has no math table", key);
        XCTAssertTrue(font.ctFont != NULL, @"Font %@ failed to load CTFont", key);

Copy link
Copy Markdown
Owner Author

@kostub kostub May 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 2510bac. fontWithName:size: always returns a non-nil MTFont, so the original XCTAssertNotNil(font) was a tautology. Replaced it with XCTAssertTrue(font.ctFont != NULL, ...) to verify the .otf actually loaded.

fontWithName:size: always returns a non-nil MTFont, so XCTAssertNotNil(font)
proved nothing. Assert font.ctFont != NULL to verify the .otf actually loaded.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@kostub kostub merged commit 754728e into master May 30, 2026
1 check passed
@kostub kostub deleted the feature/add-math-fonts-pr1 branch May 31, 2026 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant